package cn.com.headfree.mouldshow.service.impl;

import cn.com.headfree.entity.*;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.mouldshow.dao.*;
import cn.com.headfree.mouldshow.service.HumanDataTempService;
import cn.com.headfree.mouldshow.vo.TPerformanceScoreVo;
import cn.com.headfree.userinfo.dao.IUserInfoDao;
import com.google.common.base.Joiner;
import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.util.IdGen;
import com.gta.edu.sdk.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 竞赛考试信息 服务实现
 * @author smyl
 * @date 2020-06-23 15:59:50
 */
@Service("humanDataTempService")
@Transactional
public class HumanDataTempServiceImpl implements HumanDataTempService {

	@Autowired
	private HumanDataTempDao humanDataTempDao;

	@Autowired
	private IUserInfoDao iUserInfoDao;

	@Autowired
	private TPartRankTempDao tPartRankTempDao;

	@Autowired
	private TSdtPrentInfoTempDao tSdtPrentInfoTempDao;

	@Autowired
	private TSdtAwardTempDao tSdtAwardTempDao;

	@Autowired
	private TMouldInfoDao tMouldInfoDao;

	@Autowired
	private TYearEffectInfoDao tYearEffectInfoDao;

	@Autowired
	private PersonYearPointDao personYearPointDao;

	@Autowired
	private TPerformanceScoreTempDao tPerformanceScoreTempDao;

	//年度绩效
	@Value("${t_year_effect_info}")
	private String t_year_effect_info;

	/**
	 * 基本信息临时数据
	 * @param page
	 */
	@Override
	public void getTEmpBaseInfoTempPageList(Page<TEmpBaseInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTEmpBaseInfoTempPageList(page,userName,erpNo,orgId);
	}

	/**
	 * 学历信息临时数据
	 * @param page
	 */
	@Override
	public void getTEducateInfoTempPageList(Page<TEducateInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTEducateInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 工作经历临时数据
	 * @param page
	 */
	@Override
	public void getTWorkExpInfoTempPageList(Page<TWorkExpInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTWorkExpInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 继续教育及培训经历临时数据
	 * @param page
	 */
	@Override
	public void getTContiStudyInfoTempPageList(Page<TContiStudyInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTContiStudyInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 个人荣誉临时数据
	 * @param page
	 */
	@Override
	public void getTHonorInfoTempPageList(Page<THonorInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTHonorInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 竞赛考试信息临时数据
	 * @param page
	 */
	@Override
	public void getTContestInfoTempPageList(Page<TContestInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTContestInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 专家人才临时数据
	 * @param page
	 */
	@Override
	public void getTExpertTitleInfoTempPageList(Page<TExpertTitleInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTExpertTitleInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 专业技术资格临时数据
	 * @param page
	 */
	@Override
	public void getTProTecInfoTempPageList(Page<TProTecInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTProTecInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 技能等级临时数据
	 * @param page
	 */
	@Override
	public void getTSkillLevelInfoTempPageList(Page<TSkillLevelInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTSkillLevelInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 导师带徒临时数据
	 * @param page
	 */
	@Override
	public void getTSdtTutorPrentInfoTempPageList(Page<TSdtTutorPrentInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTSdtTutorPrentInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 年度绩效临时数据
	 * @param page
	 */
	@Override
	public void getTYearEffectInfoTempPageList(Page<TYearEffectInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTYearEffectInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 学术成果临时数据
	 * @param page
	 */
	@Override
	public void getTAcadeAchiveInfoTempPageList(Page<TAcadeAchiveInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTAcadeAchiveInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 标准制定临时数据
	 * @param page
	 */
	@Override
	public void getTStandInfoTempPageList(Page<TStandInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTStandInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 专利信息临时数据
	 * @param page
	 */
	@Override
	public void getTPatentInfoTempPageList(Page<TPatentInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTPatentInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 技艺革新临时数据
	 * @param page
	 */
	@Override
	public void getTTecInnovInfoTempPageList(Page<TTecInnovInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTTecInnovInfoTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 科技创新成果临时数据
	 * @param page
	 */
	@Override
	public void getTTecManInnovTempPageList(Page<TTecManInnovTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTTecManInnovTempPageList(page,userName,erpNo,orgId);
	}
	/**
	 * 项目课题成果临时数据
	 * @param page
	 */
	@Override
	public void getTProjAchieveInfoTempPageList(Page<TProjAchieveInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTProjAchieveInfoTempPageList(page,userName,erpNo,orgId);
	}

	/**
	 * 员工流动临时数据
	 * @param page
	 */
	@Override
	public void getTEmployeeMobilityTempPageList(Page<TEmployeeMobilityTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTEmployeeMobilityTempPageList(page,userName,erpNo,orgId);
	}

	/**
	 * 挂职轮岗临时数据
	 * @param page
	 */
	@Override
	public void getTRotationInfoTempPageList(Page<TRotationInfoTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTRotationInfoTempPageList(page,userName,erpNo,orgId);
	}

	/**
	 * 绩效积分临时数据
	 * @param page
	 */
	@Override
	public void getTPerformanceScoreTempPageList(Page<TPerformanceScoreTemp> page,String userName,String erpNo,String orgId) {
		humanDataTempDao.getTPerformanceScoreTempPageList(page,userName,erpNo,orgId);
	}

	/**
	 * 将数据从临时库导入到正式库
	 * @param easyName
	 * @param idList
	 */
	@Override
	public String importHumanDatas(String easyName, List<String> idList, User user) {
		String result = "";
		switch (easyName){
			case "jbxx"://基本信息临时数据
				importTEmpBaseInfoList(idList,user);
				break;
			case "xlxx"://学历信息临时数据
				importTEducateInfoList(idList,user);
				break;
			case "gzjl"://工作经历临时数据
				importTWorkExpInfoList(idList,user);
				break;
			case "pxsk"://教育培训及授课信息临时数据
				importTContiStudyInfoList(idList,user);
				break;
			case "grry"://个人荣誉临时数据
				importTHonorInfoList(idList,user);
				break;
			case "jsks"://竞赛考试临时数据
				importTContestInfoList(idList,user);
				break;
			case "zjrc"://专家人才临时数据
				importTExpertTitleInfoList(idList,user);
				break;
			case "zyzg"://专业资格临时数据
				importTProTecInfoList(idList,user);
				break;
			case "jndj"://技能等级临时数据
				importTSkillLevelInfoList(idList,user);
				break;
			case "dsdt"://导师带徒临时数据
				importTSdtTutorPrentInfoList(idList,user);
				break;
			case "ndjx"://年度绩效临时数据
				importTYearEffectInfoList(idList,user);
				break;
			case "xscg"://学术成果临时数据
				importTAcadeAchiveInfoList(idList,user);
				break;
			case "zdbz"://制度标准临时数据
				importTStandInfoList(idList,user);
				break;
			case "zlxx"://专利临时数据
				importTPatentInfoList(idList,user);
				break;
			case "jygx"://技艺革新临时数据
				importTTecInnovInfoList(idList,user);
				break;
			case "kjcx"://科技创新临时数据
				importTTecManInnovList(idList,user);
				break;
			case "ktcg"://课题成果临时数据
				importTProjAchieveInfoList(idList,user);
				break;
			case "ygld"://员工流动临时数据
				importTEmployeeMobilityList(idList,user);
				break;
			case "gzlg"://挂职轮岗临时数据
				importTRotationInfoList(idList,user);
				break;
			case "jxjf"://绩效积分临时数据
				result = importTPerformanceScoreList(idList,user);
				break;
		}
		return result;
	}

	//基本信息导入(基本信息暂不导入)
	public void importTEmpBaseInfoList(List<String> idList,User user){
		List<TEmpBaseInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTEmpBaseInfoTempByOrgId(orgId);
		if(idList.size() > 0){//插入选中项
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TEmpBaseInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				if(StringUtils.isNotBlank(p.getErpNo())){
					//每个人基本信息只能有一条，先删除原来存在的当前人基本数据
					iUserInfoDao.deleteEmpBaseInfoByErpNo(p.getErpNo());
					p.setFlowStatus(1);//默认审批通过
					iUserInfoDao.addBaseInfo(p);
				}
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTEmpBaseInfoTempByCondition(null,p);
			});
		}else{//插入全部
			list.forEach(p ->{
				if(StringUtils.isNotBlank(p.getErpNo())) {
					//每个人基本信息只能有一条，先删除原来存在的当前人基本数据
					iUserInfoDao.deleteEmpBaseInfoByErpNo(p.getErpNo());
					p.setFlowStatus(1);//默认审批通过
					iUserInfoDao.addBaseInfo(p);
				}
			});
			//删除临时库数据
			humanDataTempDao.deleteTEmpBaseInfoTempByCondition(orgId,null);
		}
	}
	//学历信息导入
	public void importTEducateInfoList(List<String> idList,User user){
		List<TEducateInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTEducateInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TEducateInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addEducateInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTEducateInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addEducateInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTEducateInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 工作经历导入
	 * @param idList
	 * @param user
	 */
	public void importTWorkExpInfoList(List<String> idList,User user){
		List<TWorkExpInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTWorkExpInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TWorkExpInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addWorkExpInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTWorkExpInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addWorkExpInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTWorkExpInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 教育培训及授课导入
	 * @param idList
	 * @param user
	 */
	public void importTContiStudyInfoList(List<String> idList,User user){
		List<TContiStudyInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTContiStudyInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TContiStudyInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addContiStudyInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTContiStudyInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addContiStudyInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTContiStudyInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 个人荣誉导入
	 * @param idList
	 * @param user
	 */
	public void importTHonorInfoList(List<String> idList,User user){
		List<THonorInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTHonorInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<THonorInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);;//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addHonorInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTHonorInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addHonorInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTHonorInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 竞赛考试导入
	 * @param idList
	 * @param user
	 */
	public void importTContestInfoList(List<String> idList,User user){
		List<TContestInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTContestInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TContestInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addContestInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTContestInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addContestInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTContestInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 专家人才导入
	 * @param idList
	 * @param user
	 */
	public void importTExpertTitleInfoList(List<String> idList,User user){
		List<TExpertTitleInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTExpertTitleInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TExpertTitleInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addExpertTitleInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTExpertTitleInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addExpertTitleInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTExpertTitleInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 专业技术资格导入
	 * @param idList
	 * @param user
	 */
	public void importTProTecInfoList(List<String> idList,User user){
		List<TProTecInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTProTecInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TProTecInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addProTecInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTProTecInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addProTecInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTProTecInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 技能等级导入
	 * @param idList
	 * @param user
	 */
	public void importTSkillLevelInfoList(List<String> idList,User user){
		List<TSkillLevelInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTSkillLevelInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TSkillLevelInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addSkillLevelInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTSkillLevelInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addSkillLevelInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTSkillLevelInfoTempByCondition(orgId,null);
		}
	}

	//师带徒信息导入
	public void importTSdtTutorPrentInfoList(List<String> idList,User user){
		String orgId = user.getBaseOrgId();
		//按单位查找所有师带徒信息
		List<TSdtTutorPrentInfo> tutorList = humanDataTempDao.getTSdtTutorPrentInfoTempByOrgId(orgId);
		//按单位查找所有徒弟信息
		List<TSdtPrentInfo> prentList = humanDataTempDao.getTSdtPrentInfoTempByOrgId(orgId);
		//按单位查找所有徒弟所获奖项信息
		List<TSdtAward> awardList = humanDataTempDao.getTSdtAwardTempByOrgId(orgId);
		//如果是有选中进行入库
		if(idList.size() > 0){
			//师带徒信息--过滤获取所有信息中包含idList中存储的id的信息
			List<TSdtTutorPrentInfo> tutorCollect = tutorList.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			tutorCollect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addSdtTutorPrentInfo(p);
			});
			//师带徒徒弟信息--过滤获取所有信息中包含idList中存储的sdtId的信息
			List<TSdtPrentInfo> prentCollect = prentList.stream().filter(entity -> idList.contains(entity.getSdtId())).collect(Collectors.toList());
			List<String> prentIdList = new ArrayList<String>();
			prentCollect.forEach(p ->{
				iUserInfoDao.addSdtPrentInfo(p);
				prentIdList.add(p.getId());
			});
			//师带徒徒弟所获奖项信息--过滤获取所有信息中包含prentCollect中存储SdtTdId的信息
			List<TSdtAward> awardCollect = awardList.stream().filter(entity -> prentIdList.contains(entity.getSdtTdId())).collect(Collectors.toList());
			awardCollect.forEach(p ->{
				iUserInfoDao.addSdtAwardInfo(p);
			});
			//删除师带徒信息临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTSdtTutorPrentInfoTempByCondition(null,p);
			});
			//删除师带徒徒弟信息临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTSdtPrentInfoTempByCondition(null,p);
			});
			//删除师带徒徒弟所获奖项临时库数据
			prentCollect.forEach(p ->{
				humanDataTempDao.deleteTSdtAwardTempByCondition(null,p.getId());
			});
		}else{//如果是全部选择入库
			//师带徒信息添加
			tutorList.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addSdtTutorPrentInfo(p);
			});
			//徒弟信息添加
			prentList.forEach(p ->{
				iUserInfoDao.addSdtPrentInfo(p);
			});
			//徒弟所获奖项信息添加
			awardList.forEach(p ->{
				iUserInfoDao.addSdtAwardInfo(p);
			});
			//删除师带徒临时库数据
			humanDataTempDao.deleteTSdtTutorPrentInfoTempByCondition(orgId,null);
			//删除徒弟临时库数据
			humanDataTempDao.deleteTSdtPrentInfoTempByCondition(orgId,null);
			//删除徒弟所获奖项临时库数据
			humanDataTempDao.deleteTSdtAwardTempByCondition(orgId,null);
		}
	}

	/**
	 * 年度绩效导入
	 * @param idList
	 * @param user
	 */
	public void importTYearEffectInfoList(List<String> idList,User user){
		List<TYearEffectInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTYearEffectInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TYearEffectInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addYearEffect(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTYearEffectInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addYearEffect(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTYearEffectInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 学术信息导入
	 * @param idList
	 * @param user
	 */
	public void importTAcadeAchiveInfoList(List<String> idList,User user){
		String orgId = user.getBaseOrgId();
		List<TAcadeAchiveInfo> list = humanDataTempDao.getTAcadeAchiveInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TAcadeAchiveInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addAcadeAchiveInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTAcadeAchiveInfoTempByCondition(null,p);
			});
		}else{
			//学术类型数据添加
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addAcadeAchiveInfo(p);
			});
			//删除学术临时库数据
			humanDataTempDao.deleteTAcadeAchiveInfoTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}


	/**
	 * 标准制定导入
	 * @param idList
	 * @param user
	 */
	public void importTStandInfoList(List<String> idList,User user){
		String orgId = user.getBaseOrgId();
		List<TStandInfo> list = humanDataTempDao.getTStandInfoTempByOrgId(orgId);
//		List<TPartRank> rankList = humanDataTempDao.getTPartRankTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TStandInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addStandInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTStandInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addStandInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTStandInfoTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}

	/**
	 * 专利信息导入
	 * @param idList
	 * @param user
	 */
	public void importTPatentInfoList(List<String> idList,User user){
		List<TPatentInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTPatentInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TPatentInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addPatentInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTPatentInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addPatentInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTPatentInfoTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}

	/**
	 * 技艺革新导入
	 * @param idList
	 * @param user
	 */
	public void importTTecInnovInfoList(List<String> idList,User user){
		List<TTecInnovInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTTecInnovInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TTecInnovInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addTecInnovInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTTecInnovInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addTecInnovInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTTecInnovInfoTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}

	/**
	 * 科技创新管理导入
	 * @param idList
	 * @param user
	 */
	public void importTTecManInnovList(List<String> idList,User user){
		List<TTecManInnov> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTTecManInnovTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TTecManInnov> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addTecManInnov(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTTecManInnovTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addTecManInnov(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTTecManInnovTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}

	/**
	 * 项目课题成果导入
	 * @param idList
	 * @param user
	 */
	public void importTProjAchieveInfoList(List<String> idList,User user){
		List<TProjAchieveInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTProjAchieveInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TProjAchieveInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addProjAchieveInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTProjAchieveInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addProjAchieveInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTProjAchieveInfoTempByCondition(orgId,null);
		}
		solveTPartRankData(idList,orgId);
	}

	/**
	 * 员工流动导入
	 * @param idList
	 * @param user
	 */
	public void importTEmployeeMobilityList(List<String> idList,User user){
		List<TEmployeeMobility> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTEmployeeMobilityTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TEmployeeMobility> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addEmployeeMobility(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTEmployeeMobilityTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addEmployeeMobility(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTEmployeeMobilityTempByCondition(orgId,null);
		}
	}

	/**
	 * 挂职轮岗导入
	 * @param idList
	 * @param user
	 */
	public void importTRotationInfoList(List<String> idList,User user){
		List<TRotationInfo> list = new ArrayList<>();
		String orgId = user.getBaseOrgId();
		list = humanDataTempDao.getTRotationInfoTempByOrgId(orgId);
		if(idList.size() > 0){
			//过滤获取所有信息中包含idList中存储的id的信息
			List<TRotationInfo> collect = list.stream().filter(entity -> idList.contains(entity.getId())).collect(Collectors.toList());
			collect.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addRotationInfo(p);
			});
			//删除临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTRotationInfoTempByCondition(null,p);
			});
		}else{
			list.forEach(p ->{
				p.setFlowStatus(1);//默认审批通过
				p.setIsValid(0);//默认有效
				p.setOrgId(user.getBaseOrgId());//单位id
				iUserInfoDao.addRotationInfo(p);
			});
			//删除临时库数据
			humanDataTempDao.deleteTRotationInfoTempByCondition(orgId,null);
		}
	}

	/**
	 * 绩效积分导入
	 * @param idList
	 * @param user
	 */
	public String importTPerformanceScoreList(List<String> idList,User user){
		String result = "";
		List<TPerformanceScoreTemp> list = new ArrayList<>();
		list = humanDataTempDao.getTPerformanceScoreTempByIds(Joiner.on("','").join(idList));
		//今年只能导入去年的数据
		Calendar date = Calendar.getInstance();
		int currentYear = Integer.valueOf(date.get(Calendar.YEAR));
		int lastYear = currentYear - 1;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//不符合规范数据条数
		int num = 0;
		if(idList.size() > 0){
			for(int i=0;i<list.size();i++){
				TPerformanceScoreTemp tPerformanceScoreTemp = list.get(i);
				if(lastYear == tPerformanceScoreTemp.getYear()){
					//批量导入人员绩效或积分时，当该人员处在薪档提交审核时或审核通过后，不予提交成功（做限制）
					List<TSalaryInfo> salaryInfoList = tYearEffectInfoDao.getSalaryInfoList(tPerformanceScoreTemp.getErpNo(),tPerformanceScoreTemp.getYear());
					//auditStatus: {'0': '待审核', '1': '审核通过','2': '审核不通过', '3': '已结束'}
					if(salaryInfoList.size()>0&&StringUtils.isNotBlank(salaryInfoList.get(0).getAuditStatus())&&!salaryInfoList.get(0).getAuditStatus().equals("2")){
						num++;
					}else{
						//---------------------------------表TYearEffectInfo操作开始------------------------------------
						//先查询这个人在去年有没有绩效积分记录,如果有记录则更新记录，如果没有记录则新增记录
						List<TYearEffectInfo> yearEffectInfosList = tYearEffectInfoDao.getTYearEffectInfoByErpNo(tPerformanceScoreTemp.getErpNo(),tPerformanceScoreTemp.getYear());
						if(yearEffectInfosList.size()>0){
							tYearEffectInfoDao.updateTYearEffectInfoByCondition(tPerformanceScoreTemp.getErpNo(),tPerformanceScoreTemp.getYear(),tPerformanceScoreTemp.getPerforGrade());
						}else{
							TYearEffectInfo tYearEffectInfo = new TYearEffectInfo();
							String id = IdGen.uuid();
							tYearEffectInfo.setId(id);
							tYearEffectInfo.setErpNo(tPerformanceScoreTemp.getErpNo());
							tYearEffectInfo.setUserName(tPerformanceScoreTemp.getUserName());
	//						tYearEffectInfo.setRateYearStart(sdf.parse(lastYear + "-01-01 00:00:00"));
	//						tYearEffectInfo.setRateYearEnd(new Date(lastYear + "-12-31"));
							tYearEffectInfo.setRateYear(lastYear);
							tYearEffectInfo.setPerforGrade(tPerformanceScoreTemp.getPerforGrade());
	//						tYearEffectInfo.setCurInte();
							tYearEffectInfo.setCreaterId(user.getFax());
							tYearEffectInfo.setCreaterName(user.getName());
							tYearEffectInfo.setCreateTime(new Date());
							tYearEffectInfo.setUpdaterId(user.getFax());
							tYearEffectInfo.setUpdaterName(user.getName());
							tYearEffectInfo.setUpdateTime(new Date());
							tYearEffectInfo.setDelSign(0);
							tYearEffectInfo.setIsValid(0);
							tYearEffectInfo.setOrignalId(id);
							tYearEffectInfo.setFlowStatus(1);
							//年度绩效id
							tYearEffectInfo.setBusinessTypeId(t_year_effect_info);
							tYearEffectInfo.setPrimitiveId(id);
							tYearEffectInfo.setIsCover(0);
							iUserInfoDao.addYearEffect(tYearEffectInfo);
						}
						//---------------------------------表TYearEffectInfo操作结束------------------------------------


						//---------------------------------表TPersonYearPoint操作开始------------------------------------
						List<TPersonYearPoint> personYearPointList = personYearPointDao.getLastYearPointByErpNo(tPerformanceScoreTemp.getErpNo(),tPerformanceScoreTemp.getYear()-1);
						if(personYearPointList.size()>0){
							personYearPointDao.updateTPersonYearPointByCondition(tPerformanceScoreTemp.getErpNo(),tPerformanceScoreTemp.getYear()-1,tPerformanceScoreTemp.getRemainPoint(),
									tPerformanceScoreTemp.getSalaryGrade());
						}else{
							TPersonYearPoint tPersonYearPoint = new TPersonYearPoint();
							tPersonYearPoint.setId(IdGen.uuid());
							tPersonYearPoint.setErpNo(tPerformanceScoreTemp.getErpNo());
							tPersonYearPoint.setUserName(tPerformanceScoreTemp.getUserName());
							tPersonYearPoint.setYear(tPerformanceScoreTemp.getYear()-1);
							tPersonYearPoint.setRemainPoint(tPerformanceScoreTemp.getRemainPoint());
							tPersonYearPoint.setSalaryGrade(tPerformanceScoreTemp.getSalaryGrade());
							tPersonYearPoint.setCreaterId(user.getFax());
							tPersonYearPoint.setCreaterName(user.getName());
							tPersonYearPoint.setCreateTime(new Date());
							tPersonYearPoint.setUpdaterId(user.getFax());
							tPersonYearPoint.setUpdaterName(user.getName());
							tPersonYearPoint.setUpdateTime(new Date());
							tPersonYearPoint.setDelSign(0);
							iUserInfoDao.addPersonYearPoint(tPersonYearPoint);
						}
						//---------------------------------表TPersonYearPoint操作结束------------------------------------
						//删除临时库数据
						humanDataTempDao.deleteTPerformanceScoreTempByCondition(null,tPerformanceScoreTemp.getId());
					}
				}else{
					num++;
				}
			}
		}
		if(num>0){
			result = "今年只能导入去年的绩效积分数据并且当该人员处在薪档提交审核时或审核通过后，不予提交成功，有"+ num +"条数据不符合规范！";
		}
		return result;
	}


	/**
	 * 导入正式库后删除临时库数据
	 * @param easyName
	 * @param id
	 */
	@Override
	public void deleteTempDataInfoById(String easyName, String id) {
		switch (easyName){
			case "jbxx"://基本信息临时数据
				humanDataTempDao.deleteTEmpBaseInfoTempByCondition(null,id);
				break;
			case "xlxx"://学历信息临时数据
				humanDataTempDao.deleteTEducateInfoTempByCondition(null,id);
				break;
			case "gzjl"://工作经历临时数据
				humanDataTempDao.deleteTWorkExpInfoTempByCondition(null,id);
				break;
			case "pxsk"://教育培训及授课信息临时数据
				humanDataTempDao.deleteTContiStudyInfoTempByCondition(null,id);
				break;
			case "grry"://个人荣誉临时数据
				humanDataTempDao.deleteTHonorInfoTempByCondition(null,id);
				break;
			case "jsks"://竞赛考试临时数据
				humanDataTempDao.deleteTContestInfoTempByCondition(null,id);
				break;
			case "zjrc"://专家人才临时数据
				humanDataTempDao.deleteTExpertTitleInfoTempByCondition(null,id);
				break;
			case "zyzg"://专业资格临时数据
				humanDataTempDao.deleteTProTecInfoTempByCondition(null,id);
				break;
			case "jndj"://技能等级临时数据
				humanDataTempDao.deleteTSkillLevelInfoTempByCondition(null,id);
				break;
			case "dsdt"://导师带徒临时数据
				humanDataTempDao.deleteTSdtTutorPrentInfoTempByCondition(null,id);
				break;
			case "ndjx"://年度绩效临时数据
				humanDataTempDao.deleteTYearEffectInfoTempByCondition(null,id);
				break;
			case "xscg"://学术成果临时数据
				humanDataTempDao.deleteTAcadeAchiveInfoTempByCondition(null,id);
				break;
			case "zdbz"://制度标准临时数据
				humanDataTempDao.deleteTStandInfoTempByCondition(null,id);
				break;
			case "zlxx"://专利临时数据
				humanDataTempDao.deleteTPatentInfoTempByCondition(null,id);
				break;
			case "jygx"://技艺革新临时数据
				humanDataTempDao.deleteTTecInnovInfoTempByCondition(null,id);
				break;
			case "kjcx"://科技创新临时数据
				humanDataTempDao.deleteTTecManInnovTempByCondition(null,id);
				break;
			case "ktcg"://课题成果临时数据
				humanDataTempDao.deleteTProjAchieveInfoTempByCondition(null,id);
				break;
			case "ygld"://员工流动临时数据
				humanDataTempDao.deleteTEmployeeMobilityTempByCondition(null,id);
				break;
			case "gzlg"://挂职轮岗临时数据
				humanDataTempDao.deleteTRotationInfoTempByCondition(null,id);
				break;
			case "jxjf"://绩效积分临时数据
				humanDataTempDao.deleteTPerformanceScoreTempByCondition(null,id);
				break;
		}
	}

	@Override
	public TEmpBaseInfoTemp getTEmpBaseInfoTempById(String id) {
		return humanDataTempDao.getTEmpBaseInfoTempById(id);
	}

	@Override
	public TEducateInfoTemp getTEducateInfoTempById(String id) {
		return humanDataTempDao.getTEducateInfoTempById(id);
	}

	@Override
	public TWorkExpInfoTemp getTWorkExpInfoTempById(String id) {
		return humanDataTempDao.getTWorkExpInfoTempById(id);
	}

	@Override
	public TContiStudyInfoTemp getTContiStudyInfoTempById(String id) {
		return humanDataTempDao.getTContiStudyInfoTempById(id);
	}

	@Override
	public THonorInfoTemp getTHonorInfoTempById(String id) {
		return humanDataTempDao.getTHonorInfoTempById(id);
	}

	@Override
	public TContestInfoTemp getTContestInfoTempById(String id) {
		return humanDataTempDao.getTContestInfoTempById(id);
	}

	@Override
	public TExpertTitleInfoTemp getTExpertTitleInfoTempById(String id) {
		return humanDataTempDao.getTExpertTitleInfoTempById(id);
	}

	@Override
	public TProTecInfoTemp getTProTecInfoTempById(String id) {
		return humanDataTempDao.getTProTecInfoTempById(id);
	}

	@Override
	public TSkillLevelInfoTemp getTSkillLevelInfoTempById(String id) {
		return humanDataTempDao.getTSkillLevelInfoTempById(id);
	}

	//导师带徒
	@Override
	public TSdtTutorPrentInfoTemp getTSdtTutorPrentInfoTempById(String id) {
		List<TSdtPrentInfoTemp> prentInfoTemps = humanDataTempDao.getTSdtPrentInfoTempListBySdtId(id);
		TSdtTutorPrentInfoTemp tSdtTutorPrentInfoTemp = humanDataTempDao.getTSdtTutorPrentInfoTempById(id);
		if(prentInfoTemps != null && prentInfoTemps.size()>0){
			prentInfoTemps.forEach(p ->{
				List<TSdtAwardTemp> tSdtAwardTemps = humanDataTempDao.getTSdtAwardTempListBySdtTdId(p.getId());
				p.settSdtAwardList(tSdtAwardTemps);
			});
		}
		tSdtTutorPrentInfoTemp.settSdtPrentInfo(prentInfoTemps);
		return tSdtTutorPrentInfoTemp;
	}

	@Override
	public TYearEffectInfoTemp getTYearEffectInfoTempById(String id) {
		return humanDataTempDao.getTYearEffectInfoTempById(id);
	}

	//学术成果
	@Override
	public TAcadeAchiveInfoTemp getTAcadeAchiveInfoTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TAcadeAchiveInfoTemp tAcadeAchiveInfoTemp = humanDataTempDao.getTAcadeAchiveInfoTempById(id);
		tAcadeAchiveInfoTemp.settPartRankList(ranks);
		return tAcadeAchiveInfoTemp;
	}

	//标准制定
	@Override
	public TStandInfoTemp getTStandInfoTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TStandInfoTemp tStandInfoTemp = humanDataTempDao.getTStandInfoTempById(id);
		tStandInfoTemp.settPartRankList(ranks);
		return tStandInfoTemp;
	}

	//专利信息
	@Override
	public TPatentInfoTemp getTPatentInfoTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TPatentInfoTemp tPatentInfoTemp = humanDataTempDao.getTPatentInfoTempById(id);
		tPatentInfoTemp.settPartRankList(ranks);
		return tPatentInfoTemp;
	}

	//技艺革新
	@Override
	public TTecInnovInfoTemp getTTecInnovInfoTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TTecInnovInfoTemp tTecInnovInfoTemp = humanDataTempDao.getTTecInnovInfoTempById(id);
		tTecInnovInfoTemp.settPartRankList(ranks);
		return tTecInnovInfoTemp;
	}

	//科技及创新管理
	@Override
	public TTecManInnovTemp getTTecManInnovTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TTecManInnovTemp tTecManInnovTemp = humanDataTempDao.getTTecManInnovTempById(id);
		tTecManInnovTemp.settPartRankList(ranks);
		return tTecManInnovTemp;
	}

	//项目课题成果
	@Override
	public TProjAchieveInfoTemp getTProjAchieveInfoTempById(String id) {
		List<TPartRankTemp> ranks = humanDataTempDao.getTPartRankTempListByItemId(id);
		TProjAchieveInfoTemp tProjAchieveInfoTemp = humanDataTempDao.getTProjAchieveInfoTempById(id);
		tProjAchieveInfoTemp.settPartRankList(ranks);
		return tProjAchieveInfoTemp;
	}

	@Override
	public TEmployeeMobilityTemp getTEmployeeMobilityTempById(String id) {
		return humanDataTempDao.getTEmployeeMobilityTempById(id);
	}

	@Override
	public TRotationInfoTemp getTRotationInfoTempById(String id) {
		return humanDataTempDao.getTRotationInfoTempById(id);
	}

	@Override
	public TPerformanceScoreTemp getTPerformanceScoreTempById(String id) {
		return humanDataTempDao.getTPerformanceScoreTempById(id);
	}

	/*******************************根据id修改数据***********************************/

	@Override
	public void updateBaseInfoTempById(TEmpBaseInfoTemp tEmpBaseInfoTemp) {
		humanDataTempDao.updateBaseInfoTempById(tEmpBaseInfoTemp);
	}

	@Override
	public void updateTEducateInfoTempById(TEducateInfoTemp tEducateInfoTemp) {
		humanDataTempDao.updateTEducateInfoTempById(tEducateInfoTemp);
	}

	@Override
	public void updateTWorkExpInfoTempById(TWorkExpInfoTemp tWorkExpInfoTemp) {
		humanDataTempDao.updateTWorkExpInfoTempById(tWorkExpInfoTemp);
	}

	@Override
	public void updateTContiStudyInfoTempById(TContiStudyInfoTemp tContiStudyInfoTemp) {
		humanDataTempDao.updateTContiStudyInfoTempById(tContiStudyInfoTemp);
	}

	@Override
	public void updateTHonorInfoTempById(THonorInfoTemp tHonorInfoTemp) {
		humanDataTempDao.updateTHonorInfoTempById(tHonorInfoTemp);
	}

	@Override
	public void updateTContestInfoTempById(TContestInfoTemp tContestInfoTemp) {
		humanDataTempDao.updateTContestInfoTempById(tContestInfoTemp);
	}

	@Override
	public void updateTExpertTitleInfoTempById(TExpertTitleInfoTemp tExpertTitleInfoTemp) {
		humanDataTempDao.updateTExpertTitleInfoTempById(tExpertTitleInfoTemp);
	}

	@Override
	public void updateTProTecInfoTempById(TProTecInfoTemp tProTecInfoTemp) {
		humanDataTempDao.updateTProTecInfoTempById(tProTecInfoTemp);
	}

	@Override
	public void updateTSkillLevelInfoTempById(TSkillLevelInfoTemp tSkillLevelInfoTemp) {
		humanDataTempDao.updateTSkillLevelInfoTempById(tSkillLevelInfoTemp);
	}

	@Override
	public void updateTPerformanceScoreTempById(TPerformanceScoreTemp tPerformanceScoreTemp) {
		humanDataTempDao.updateTPerformanceScoreTempById(tPerformanceScoreTemp);
	}

	//师带徒信息
	@Override
	public void updateTSdtTutorPrentInfoTempById(TSdtTutorPrentInfoTemp tSdtTutorPrentInfoTemp,User user) {
		List<TSdtPrentInfoTemp> prentInfoTemps = tSdtTutorPrentInfoTemp.gettSdtPrentInfo();
		//再删除徒弟信息
		humanDataTempDao.deleteTSdtPrentInfoTempByCondition(null,tSdtTutorPrentInfoTemp.getId());
		//再添加徒弟所获信息
		prentInfoTemps.forEach(p ->{
			p.setSdtId(tSdtTutorPrentInfoTemp.getId());
			tSdtPrentInfoTempDao.saveInfo(p);
			//先删除徒弟所获奖项
			humanDataTempDao.deleteTSdtAwardTempByCondition(null,p.getId());
			List<TSdtAwardTemp> tSdtAwardTemps = p.gettSdtAwardList();
			//再添加
			if(tSdtAwardTemps != null && tSdtAwardTemps.size()>0){
				tSdtAwardTemps.forEach( t ->{
					t.setId(IdGen.uuid());
					t.setSdtTdId(p.getId());
					t.setOrgId(user.getBaseOrgId());
					tSdtAwardTempDao.saveInfo(t);
				});
			}
		});
		humanDataTempDao.updateTSdtTutorPrentInfoTempById(tSdtTutorPrentInfoTemp);
	}

	@Override
	public void updateTYearEffectInfoTempById(TYearEffectInfoTemp tYearEffectInfoTemp) {
		humanDataTempDao.updateTYearEffectInfoTempById(tYearEffectInfoTemp);
	}

	//学术成果
	@Override
	public void updateTAcadeAchiveInfoTempById(TAcadeAchiveInfoTemp tAcadeAchiveInfoTemp,User user) {
		List<TPartRankTemp> rankTemps = tAcadeAchiveInfoTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tAcadeAchiveInfoTemp.getId(),user,"12");
		humanDataTempDao.updateTAcadeAchiveInfoTempById(tAcadeAchiveInfoTemp);
	}

	//标准制定
	@Override
	public void updateTStandInfoTempById(TStandInfoTemp tStandInfoTemp,User user) {
		List<TPartRankTemp> rankTemps = tStandInfoTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tStandInfoTemp.getId(),user,"13");
		humanDataTempDao.updateTStandInfoTempById(tStandInfoTemp);
	}

	//专利信息
	@Override
	public void updateTPatentInfoTempById(TPatentInfoTemp tPatentInfoTemp,User user) {
		List<TPartRankTemp> rankTemps = tPatentInfoTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tPatentInfoTemp.getId(),user,"14");
		humanDataTempDao.updateTPatentInfoTempById(tPatentInfoTemp);
	}

	//技艺革新
	@Override
	public void updateTTecInnovInfoTempById(TTecInnovInfoTemp tTecInnovInfoTemp,User user) {
		List<TPartRankTemp> rankTemps = tTecInnovInfoTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tTecInnovInfoTemp.getId(),user,"15");
		humanDataTempDao.updateTTecInnovInfoTempById(tTecInnovInfoTemp);
	}

	//科技创新管理
	@Override
	public void updateTTecManInnovTempById(TTecManInnovTemp tTecManInnovTemp,User user) {
		List<TPartRankTemp> rankTemps = tTecManInnovTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tTecManInnovTemp.getId(),user,"16");
		humanDataTempDao.updateTTecManInnovTempById(tTecManInnovTemp);
	}

	//项目课题成果
	@Override
	public void updateTProjAchieveInfoTempById(TProjAchieveInfoTemp tProjAchieveInfoTemp,User user) {
		List<TPartRankTemp> rankTemps = tProjAchieveInfoTemp.gettPartRankList();
		updateTPartRankTempData(rankTemps,tProjAchieveInfoTemp.getId(),user,"17");
		humanDataTempDao.updateTProjAchieveInfoTempById(tProjAchieveInfoTemp);
	}

	/**
	 * 公共方法处理参与人员表数据
	 */

	public void solveTPartRankData(List<String> idList,String orgId){
		List<TPartRank> rankList = humanDataTempDao.getTPartRankTempByOrgId(orgId);
		if(idList.size() > 0){
			//参与人员--过滤获取所有信息中包含idList中存储的id的信息
			List<TPartRank> rankCollect = rankList.stream().filter(entity -> idList.contains(entity.getItemId())).collect(Collectors.toList());
			rankCollect.forEach(p ->{
				iUserInfoDao.addPartRank(p);
			});
			//删除参与人员临时库数据
			idList.forEach(p ->{
				humanDataTempDao.deleteTPartRankTempByCondition(null,p);
			});
		}else{
			//参与人员添加
			rankList.forEach(p ->{
				iUserInfoDao.addPartRank(p);
			});
			//删除学术临时库数据
			humanDataTempDao.deleteTPartRankTempByCondition(orgId,null);
		}
	}


	/**
	 * 公共方法添加参与人表数据
	 */
	public void updateTPartRankTempData(List<TPartRankTemp> rankTemps,String itemId,User user,String itemType){
		//先删除
		humanDataTempDao.deleteTPartRankTempByCondition(null,itemId);
		//再增加
		rankTemps.forEach(p ->{
			p.setItemId(itemId);
			p.setItemType(itemType);
			p.setId(IdGen.uuid());
			p.setIsValid(0);
			p.setOrgId(user.getBaseOrgId());
			tPartRankTempDao.saveInfo(p);
		});
	}

	public void searchPerformanceScoreList(Page<TPerformanceScoreVo> page, TPerformanceScoreVo tPerformanceScoreVo){
		if(!StringUtil.isNullOrEmpty(tPerformanceScoreVo.getBaseorgId())){
			//获取部门及其子部门信息
			tPerformanceScoreTempDao.searchPerformanceScoreList(page, tPerformanceScoreVo);
		}
	}

}
